/**
 * 菜单api
 */
import { menu, menuQuery } from '../../entity/system/menu'

export const MENU_API_PRE_SUFFER = '/menu/'

import { GetRequestApi, PostRequestApi, PutRequestApi } from '@/utils/api/RequestApi'

/**
 * 根据用户名查询导航树
 * @param name
 */
export function findNavTree(name: string) {
  return new GetRequestApi<Array<menu>>(MENU_API_PRE_SUFFER + 'findNavTree/' + name).get()
}

/**
 * 新增
 */
export function add(data: menu) {
  return new PostRequestApi<menu>(MENU_API_PRE_SUFFER, data).get()
}

/**
 * 查询菜单树
 */
export function menuTree(data: menuQuery) {
  return new PostRequestApi<Array<menu>>(MENU_API_PRE_SUFFER + 'findMenuTree', data).get()
}

/**
 * 修改
 */
export function update(data: menu) {
  return new PutRequestApi<menu>(MENU_API_PRE_SUFFER, data).get()
}

/**
 * 根据id查询
 */
export function get(id: number) {
  return new GetRequestApi<menu>(MENU_API_PRE_SUFFER + id).get()
}

/**
 * 分页查询
 */
export function page(data: menuQuery) {
  return new PostRequestApi(MENU_API_PRE_SUFFER + 'page', data).get()
}
